<script>
import { getuser, setuser, clearuser } from './utils/storage'
import { request2, wxlogin } from './utils/https'
import { getusers } from './utils/interfaces'
export default {
  async onShow () {
    const { ID } = await getuser()
    const { query, path } = wx.getLaunchOptionsSync()
    const { schoolstudentid } = query
    if (schoolstudentid) {
      // eslint-disable-next-line eqeqeq
      if (ID == schoolstudentid) return
      await clearuser()
      const code = await wxlogin()
      const data = await request2(getusers, {
        data: {
          code
        }
      })
      // eslint-disable-next-line eqeqeq
      const user = data.find(v => v.ID == schoolstudentid)
      if (user) {
        setuser(user)
        wx.reLaunch({
          url: path
        })
      }
    } else {
      if (!ID) {
        const code = await wxlogin()
        const data = await request2(getusers, {
          data: {
            code
          }
        })
        if (data.length === 0) {
          wx.reLaunch({
            url: 'pages/home/main'
          })
        } else {
          await setuser(data[0])
          wx.reLaunch({
            url: '/pages/index/main'
          })
        }
      }
    }
  }
}
</script>

<style>
page {
  width: 100%;
  height: 100%;
  background-color: #f7f7f7;
}

.container {
  display: flex;
  flex-direction: column;
  flex-basis: auto;
  box-sizing: border-box;
  min-width: 0;
  height: 100%;
  width: 100%;
}

.headre {
  box-sizing: border-box;
  flex-shrink: 0;
}

.main {
  padding-left: 15px;
  padding-right: 15px;
}

.slide-image {
  height: 100%;
  width: 100%;
  display: inline-block;
  overflow: hidden;
}
.swiper {
  height: 260rpx;
  width: 100%;
}
.list {
  margin-top: 25rpx;
  background-color: #ffffff;
  overflow: hidden;
  position: relative;
  border-radius: 0.25rem;
}
.list-header {
  padding-left: 30rpx;
  padding-top: 30rpx;
  padding-bottom: 30rpx;
}

.tab1 {
  padding-left: 40rpx;
  padding-right: 40rpx;
}

.data-li {
  border-top: 1px solid #dfdfdf;
  height: 150rpx;
  padding-left: 40rpx;
  padding-right: 40rpx;
  padding-top: 20rpx;
  padding-bottom: 20rpx;
}
.lab {
  font-size: 26rpx;
  color: #ffffff;
  line-height: 56rpx;
  background: green;
  position: absolute;
  right: 0;
  z-index: 2;
  top: 0;
  padding: 0 1.2em;
  border-radius: 2px;
  border-bottom-left-radius: 0.75em;
}

.label {
  font-size: 22rpx;
  color: #ffffff;
  height: 55rpx;
  background: red;
  position: absolute;
  right: 0rpx;
  z-index: 2;
  padding-top: 30rpx;
  -webkit-transform-origin: left bottom;
  -moz-transform-origin: left bottom;
  transform-origin: left bottom;
  -webkit-transform: translate(29.29%, -100%) rotate(45deg);
  -moz-transform: translate(29.29%, -100%) rotate(45deg);
  transform: translate(29.29%, -100%) rotate(45deg);
  text-indent: 0;
  width: 150rpx;
  text-align: center;
  line-height: 30px;
}

.bg-color-FF5033 {
  background-color: #ff5033;
}

.bg-color-FCAB37 {
  background-color: #fcab37;
}

.bg-color-0064EB {
  background-color: #0090ff;
}

.bg-color-FD7A2C {
  background-color: #fd7a2c;
}

.bg-color-05A718 {
  background-color: #05a718;
}

.text-color-939393 {
  color: #939393;
}

.text-color-7B7C7E {
  color: #7b7c7e;
}

.text-color-444547 {
  color: #444547;
}

.text-color-BDBDBD {
  color: #bdbdbd;
}

.text-color-FBFDFF {
  color: #fbfdff;
}

.text-color-1899FF {
  color: #1899ff;
}

.bigboxs {
  padding-left: 40rpx;
  padding-right: 40rpx;
  padding-top: 20rpx;
  padding-bottom: 20rpx;
  overflow: hidden;
  height: 98px;
}

.qs_btn {
  color: #fff;
  width: 92%;
  margin: 0 auto;
}
.writehomework {
  padding: 20rpx;
}

.answer {
  color: red;
}
.qs_btns {
  width: 80%;
  background: #0099ff;
  color: #fff;
  border-radius: 5px;
}
.phoned {
  flex: 30%;
}

.lidi {
  margin-bottom: 30rpx;
}
.indet {
  text-indent: 2em;
}

.bigimg {
  display: flex;
  background-color: #fff;
  margin-bottom: 30rpx;
  padding: 27rpx;
  padding-top: 40rpx;
  padding-bottom: 40rpx;
}
.data-img {
  width: 42px;
  height: 42px;
}
.txte {
  overflow: hidden;
  color: #888;
}

.dain {
  width: 24rpx;
  height: 24rpx;
  background-color: red;
  border-radius: 50%;
  position: absolute;
  right: 3px;
}

.user_info {
  background-color: #fff;
  padding: 8px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid #ebeef5;
  border-top: 1px solid #ebeef5;
  display: flex;
  flex-direction: row;
}
.user_info img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-right: 20px;
  margin: auto;
}
.user_detail h4 {
  margin-top: 82rpx;
  margin-left: 24rpx;
  font-weight: bold;
}
.user_detail {
  flex: 1;
}
.xiaoqi {
  flex: 1;
  margin: 82rpx 0;
  color: #aaa;
  font-size: 14px;
}

.order_info {
  margin-top: 16px;
}

.order_detail {
  padding: 10px 0 10px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid #ebeef5;
  background-color: #fff;
  overflow: hidden;
  font-size: 15px;
}
.order_detail image {
  width: 16px;
  height: 16px;
  margin-right: 16px;
  float: left;
  margin-top: 3px;
}
.order_detail .detail {
  font-size: 12px;
  color: #8fc31f;
  padding: 0 5px;
  background-color: #eee;
  border-radius: 20px;
  margin-right: 10px;
}
.r_icon {
  font-size: 16px;
  color: #aaa;
  float: right;
  font-weight: bold;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.r_icon img {
  width: 20px;
  height: 20px;
}

.tub {
  width: 18px; /*设置图片显示的宽*/
  height: 20px; /*图片显示的高*/
  margin-right: 10rpx;
  margin-top: 17rpx;
  margin-right: 10rpx;
  margin-left: 10rpx;
}

.login {
  width: 100%;
  height: 100%;
  position: relative;
  background-image: url(https://cdn.hterobot.com/xcx/without.png);
  background-repeat: no-repeat;
  background-size: 80%;
  background-position: center;
}

.login .learn {
  position: absolute;
  width: 100%;
  height: 100%;
  /* background-color: rgba(0, 0, 0, 0.5); */
  top: 0;
  left: 0;
}
.learn button {
  position: absolute;
  top: 90%;
  left: 10%;
  width: 80%;
  background-color: #009eef;
  color: white;
}
.latae {
  padding-bottom: 72rpx;
  background-color: #ffffff;
  margin-left: 30rpx;
  margin-right: 30rpx;
  padding-top: 72rpx;
  margin-top: 40%;
  border-radius: 5px;
  box-shadow: #eeeeee 2px 5px 5px;
}
.buttim {
  position: relative !important;
  left: 0% !important;
}

.contact {
  width: 100%;
  height: 100%;
}
.content ._img {
  width: 280px;
  margin-bottom: 60rpx;
}
.content {
  background-color: #fff;
  padding: 16px;
  box-sizing: border-box;
  position: relative;
  height: 100%;
  text-align: center;
}
.content .container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  box-sizing: border-box;
  padding: 100px 20px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  text-align: center;
}

.container h1 {
  font-size: 28px;
  font-weight: bold;
  padding: 20px 0;
}

.aspectFit {
  width: 100%;
  height: 120px;
}
.image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: black;
  z-index: 20;
}
._i-grid .col-8 {
  position: relative;
  width: 33%;
  float: left;
  box-sizing: border-box;
}
._i-grid .col-8 ._i-icon {
  position: absolute;
  right: 0;
  background-color: #8fc31f;
}

.index-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  font-weight: bold;
  height: 80rpx;
  line-height: 80rpx;
}
.lids {
  font-weight: bold;
  line-height: 32px;
}
.lids2 {
  line-height: 28px;
}
.school-button {
  display: inline-block;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
#app .i-btn-small {
  height: 24px;
  line-height: 24px;
  margin: 0;
}

#app .input-small {
  border: 1px solid #dfdfdf;
}
#app .writehomework-header {
  background-image: url(https://cdn.hterobot.com/xcx/biaoqian@2x.png);
  background-repeat: no-repeat;
  background-position-y: center;
  color: #ffffff;
}
#app .van-cell__title {
  flex: 4;
}
#app .van-cell__value {
  color: #409eff;
  background: #ecf5ff;
  border: 1px solid #b3d8ff;
  text-align: center;
  border-radius: 4px;
}

#app .school-input {
  border: 1px solid #dfdfdf;
}

#app .html {
  overflow-y: auto;
}
.float-left {
  float: left;
}
.float-right {
  float: right;
}
.clearfix {
  clear: both;
}
#app .school-button-round {
  width: 44px;
  margin-right: 6px;
}

#app .school-class {
  padding: 5px 20px;
}

#app .school-class-header {
  line-height: 26px;
  font-weight: 800;
}

#app .school-class-answer {
  line-height: 26px;
}

#app .school-class-student {
  color: #0090ff;
  display: inline-block;
  padding-left: 5px;
  padding-right: 5px;
}

#app .school-class-teacher {
  color: #0090ff;
  display: inline-block;
  padding-left: 5px;
  padding-right: 5px;
  background-color: #d5edff;
  border-radius: 4px;
}
#app .van-hairline--top-bottom:after {
  border: 0;
}
</style>
